<template>
	<view>
		<!-- 店铺信息 -->
		<view class="uni-flex uni-row uni-bg-white" 
			style="padding: 32rpx 0;padding: 30rpx 32rpx;justify-content:space-between;">
			<view class="uni-flex uni-row">
				<view>
					<image style="width:150rpx;height:150rpx;border-radius:50%;" 
					:src="user.avatar"></image>
				</view>
				<view class="uni-flex uni-column" style="margin-left:32rpx;font-size:26rpx;justify-content:center;">
					<view style="font-size:14pt;">
						<navigator url="../login/login" v-if="!user.state">
							<text>点击登录</text>
						</navigator>
						<text v-if="user.state">{{user.userName}}</text>
					</view>
					<!-- view style="color:#595959;">
						<view>
							<text>13000000000</text>
						</view>
					</view> -->
				</view>
			</view>
			<view style="display:flex;align-items:center;justify-content:center;">
				<navigator url="mine_modify" v-if="user.state">
					<button class="mini-btn" size="mini">修改资料</button>
				</navigator>
			</view>
		</view>
		
		<view>
			<view class="uni-bg-white lig-card">
				<view class="uni-flex uni-row mine_fun_item" 
					style="justify-content:space-between;"
					@click="onCoupon">
					<view class="uni-flex uni-row">
						<image src="../../static/image/coupon.png" 
							class="icon"></image>
						<text style="padding-left:20rpx;">优惠券</text>
					</view>
					<view class="uni-flex uni-column" style="justify-content:center;">
						<image class="chevron" src="../../static/image/chevron-right.png"></image>
					</view>
				</view>
				<navigator url="../address/address">
					<view class="uni-flex uni-row mine_fun_item" style="justify-content:space-between;">
						<view class="uni-flex uni-row">
							<image src="../../static/image/address.png"
								class="icon"></image>
							<text style="padding-left:20rpx;">地址薄</text>
						</view>
						<view class="uni-flex uni-column" style="justify-content:center;">
							<image class="chevron" src="../../static/image/chevron-right.png"></image>
						</view>
					</view>
				</navigator>
			</view>
			
			<view class="uni-bg-white lig-card">
				<view class="uni-flex uni-row mine_fun_item" 
					style="justify-content:space-between;"
					 @click="onService">
					<view class="uni-flex uni-row">
						<image src="../../static/image/service.png"
							class="icon"></image>
						<text style="padding-left:20rpx;">问题建议</text>
					</view>
					<view class="uni-flex uni-column" style="justify-content:center;">
						<!-- <image class="chevron" src="../../static/image/chevron-right.png"></image> -->
					</view>
				</view>
				<view class="uni-flex uni-row mine_fun_item" 
					@click="onLogout"
					v-if="user.state">
					<image src="../../static/image/exit.png" 
						class="icon"></image>
					<text style="padding-left:20rpx;">退出系统</text>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	import { image_url, APP_NAME } from "@/util/constant.js";
	import {$get} from "@/util/request.js";
	import { logout } from "@/util/api.js";
	export default {
		data() {
			return {
				user: {
					state: false,
					userName: '',
					avatar: 'https://img2.baidu.com/it/u=1477560808,3458786520&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500'
				}
			}
		},
		onLoad() {
			wx.showShareMenu({
			    withShareTicket:true,
			    // 设置下方的Menus菜单，才能够让发送给朋友与分享到朋友圈两个按钮可以点击
			    menus:["shareAppMessage","shareTimeline"]
			});
			
			let that = this;
			let userInfo = uni.getStorageSync('userInfo');
			if (userInfo != '') {
				$get('auth/get-session-info?token=' + userInfo.token).then(res => {
					if (res.data) {
						that.user.state = true;
						that.user.userName = userInfo.userName;
						if (userInfo.avatar != '') {
							that.user.avatar = image_url + userInfo.avatar;
						}
					}
				});
				
			}
		},
		// 转发给好友
		onShareAppMessage(res) {
		    if (res.from === 'button') {// 来自页面内分享按钮
		    }
		    return {
		        title: APP_NAME //分享的名称
		    }
		},
		//分享到朋友圈
		onShareTimeline(res) {
		    return {
		        title: APP_NAME,
		        type: 0,
		        summary: "",
		    }
		},
		methods: {
			onLogout() {
				logout();
			},
			onService() {
				uni.makePhoneCall({
					phoneNumber: '13989456369',//电话号码
					success:function(e){
					},
					fail:function(e){

					}
				});
			},
			onCoupon() {
				uni.showToast({
					icon: 'none',
					title: '该功能尚未开放，敬请期待'
				});
			}
		}
	}
</script>

<style>
.mine_fun_item {
	border-bottom: 2rpx solid #f5f5f5;
	padding:20rpx 20rpx;
	color:#000000;
	align-items:center;
}
.mine_fun_item .icon {
	width:50rpx;
	height:50rpx;
}
.mine_fun_item .chevron {
	width:40rpx;
	height:40rpx;
}
</style>
